const axios = require('axios');

// create an axios instance
const service = axios.create({
  baseURL: 'https://api.opendota.com/api',
  timeout: 60000
})

// request interceptor
service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    console.log(error) // for debug
    return Promise.reject(error)
  }
)

// response interceptor
service.interceptors.response.use(
  response => {
    const res = response.data
    return res
  },
  error => {
    console.log(error) // for debug
    return Promise.reject(error)
  }
)

module.exports = {
  service
}
